package com.joyintech.util;

import lombok.Data;

@Data
public class AppReply<T> {
    public static final String SUCCESS_CODE = "1";
    public static final String SUCCESS_MSG = "请求成功";
    public static final String EORRO_CODE = "0";
    public static final String ERROR_MSG = "请求失败";
    public static final String LOGIN_CODE = "2";
    public static final String LOGIN_MSG = "登录失败";
    public static final String MULTILOGIN_CODE = "3";

    private T data;
    private String msg;
    private String code;
    private Integer status;
    private String traceId;

    public AppReply(Integer status,String code, String msg, T data) {
        this.data = data;
        this.msg = msg;
        this.code = code;
        this.status = status;

    }

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }

    public static AppReply success(Object obj) {
        return new AppReply(0,"1", "请求成功", obj);
    }

    public static AppReply success(String msg) {
        return new AppReply(0,"1", msg, (Object)null);
    }

    public static AppReply success() {
        return new AppReply(0,"1", "请求成功", (Object)null);
    }

    public static AppReply error(Object obj) {
        return new AppReply(1,"0", "请求失败", obj);
    }

    public static AppReply error(String msg) {
        return new AppReply(1,"0", msg, (Object)null);
    }

    public static AppReply error(String code, String msg) {
        return new AppReply(1,code, msg, (Object)null);
    }

    public static AppReply error() {
        return new AppReply(1,"0", "请求失败", (Object)null);
    }

    public static AppReply relogin() {
        return new AppReply(1,"3", "账号已超时，请重新登录", (Object)null);
    }

    public static AppReply relogin1() {
        return new AppReply(1,"3", "账号已在别处登录，请重新登录", (Object)null);
    }

    public static AppReply login() {
        return new AppReply(1,"2", "请登录账号", (Object)null);
    }
}
